#! /usr/bin/python
#encoding=utf-8
'''
Created on 2018-7-9

@author: cooler
'''
import time
import sys
# 生产者
def produce(l):
    i=0
    while 1:
        if i < 10:
            l.append(i)
            print "------",i
            yield i
            i=i+1
            # time.sleep(1)
        else:
            return     
# 消费者
def consume(l):
    p = produce(l)
    print p.next(),l
    print p.next(),l
    print p.next(),l

    # while 1:
    #     try:
    #         p.next()
    #         while len(l) > 0:
    #             print l.pop()
    #     except StopIteration:
    #         sys.exit(0)
if __name__ == "__main__":
    l = []
    consume(l)